import axios from './axios.js'
import axios_true from 'axios'

/**
 * 获取用户信息
 */

// export const getUserInfoAgain = (val) => axios('/user/getUserInfo');
export const getUserInfoAgain = (val) => axios('/customer/getCustomer', undefined, undefined, undefined, undefined, {type:1});
// export const getUserInfoAgain = (val) => axios('/customer/refreshUserInfo');

/**
*授权登录
*/

export const accessLogin = (param) => axios('/customer/accessLogin',param, 'get', 'other', undefined,{type:1});

/**
 * 单点登录
 */

export const sendSessionId = val => axios('/user/loginVip');
// export const getSessionId = axios_true.get('/user/accessLogin?eid=138');

/**
 * 获取用户rid信息 在线客服使用
 */
export const getUcUserInfo = (val) => axios('/user/getUcUserInfo');

//getUcUserInfo
/**
 * 改变用户信息
 */

// export const changeUserInfo = param => axios('/user/updateUserInfo', param, "post", undefined, undefined);
export const changeUserInfo = param => axios('/customer/updateCustomerInfo', param, "post", undefined, undefined);


/**
 * 上传头像
 */

export const uploadAvatar = () => axios_true('', )

/**
 * 账号密码登录
 */
export const accountLogin = (mobile, password, enterpriseCode,deviceId,deviceType,appName) => axios('/customer/login', {mobile, password, enterpriseCode,deviceId,deviceType,appName}, 'POST', undefined, undefined, {type:1});

/**
 * 退出登录
 */
export const signout = param => axios('/customer/logout/', param);

/**
 * 获取注册协议
 */

 export const queryExplain = param => axios_true(api.base_host+'/expMana/queryExplain'+'?storeCode='+api.storeCode+'&typeCode=EXP_REG'+'&length=-1');


 export const findDetail = param => axios_true(api.base_host+'/expMana/findDetail'+'?expCode='+param);

// http://test.vmbase.scn.weilian.cn/expMana/findDetail?expCode=4

/**
 * 获取用户rid信息 在线客服使用
 */


export const company = param => axios('/customer/company.img', param, undefined, 'other');

/** 注册第一步
 * 获取短信验证码
 */

export const mobileCode = param => axios_true({
  method:'get',
  url: `${api.customer_host}/customer/registerStepOne/${param.phone}/${api.enterpriseCode}`,
  headers: {'sessionId': param.security, 'Content-Type':'application/json', 'Accept' : 'application/json'}
}).then(res => {return res.data});

/** 注册第二步
发送注册请求
*/

// export const register = (mobile, code, password, enterpriseId) => axios('/customer/registerStepTwo', {mobile, code, password, enterpriseId}, 'post')
export const register = (mobile, code, password, enterpriseCode) => axios('/customer/registerStepTwo', {mobile, code, password, enterpriseCode}, 'post')


/**
 * 改密码 1
 */
// export const changePassWordOne = phone => axios('/user/findPwdStepOne/', phone);
// export const changePassWordOne = phone => axios('/customer/findPwdStepOne/', phone);

export const changePassWordOne = param => axios_true({
  method:'get',
  url: `${api.customer_host}/customer/findPwdStepOne/${param.phone}/${api.enterpriseCode}`,
  headers: {'sessionId': param.security, 'Content-Type':'application/json', 'Accept' : 'application/json'}
}).then(res => {return res.data});
/**
 * 改密码 2
 */

// export const changePassWordTwo = (mobile, code, newPassword, enterpriseid) => axios('/user/findPwdStepTwo', {mobile, code, newPassword, enterpriseId
// }, 'POST');
export const changePassWordTwo = (mobile, code, newPassword, enterpriseCode) => axios('/customer/findPwdStepTwo', {mobile, code, newPassword, enterpriseCode
}, 'POST');

/**
 * 获取全部订单
 */

export const getAllOrder = num => axios('/order/selectOrderList?index=', num.index + '&pageNum=' + num.pageNum+'&pageSize=10', undefined, undefined,true, {type:1});

  


 /**
  * 未付款订单
  */

export const willPay = param => axios('/order/goPay/', param);


 /**
 * 取消订单
 */

export const cancelOrder = orderNo => axios('/order/cancel', {orderNo} , 'post', undefined, true);


 /**
 * 订单确认收货
 */

export const confirmOrder = orderNo => axios('/order/confirmOrder', {orderNo} , 'post' , undefined, true);

export const confirmPayment = orderNo => axios('/order/queryYiPayStatus/', orderNo, 'get', undefined, {config:2});

/**
 * 获取包裹详情
 */

export  const packageDetail = param => axios('/orderPackage/packageDetail', param, undefined, undefined, true);

 /**
 * 省市区
 */

export const select = param => axios_true(api.base_host+'/address/select/'+param).then(res => {return res.data.data});

  /**
 * 查看订单详情 用来找到自提订单的服务商信息
 */

export const orderDetails = val => axios('/order/selectOrderDetail/', val, undefined, undefined, true);

  /**
 * 订单评价查询标签
 */

export const selectCommentConfig = val => axios('/commentConfig/selectCommentConfig', val);
 /**
 * 订单评价提交
 */
export const saveGoodsComment = val => axios('/goodsComment/saveOrderComment', val, 'post');

/**
 * 获取全部订单数量;
 */

export const countByStatus = num => axios('/order/countByStatus', undefined, undefined, undefined, true);

/**
 * 扫码购是否核销;
 */

export const getCancellationStatus = num => axios('/order/getCancellationStatus/', num, undefined, undefined, true, {type:1});

 /**
 * 以下为安装单接口
 */

 /**
 * 获取安装单信息
 */


export const getInstall = param => axios('/valueAdded/selectSpStInstallList/', param);


 /**
 * 新增安装单信息
 */


export const setInstall = data => axios('/valueAdded/insertSpStInstall', data, 'post');

/**
 * 更新安装单
 */

export const upDateInstall = data => axios('/valueAdded/updateSpStInstall', data, 'put');
/**
* 获取维保单信息
*/


export const getMaintain = data => axios('/valueAdded/selectSpFxMaintenanceList/',data)


/**
* 新增维保单信息
*/


export const addMaintain = data => axios('/valueAdded/insertSpFxMaintenance', data, 'post')

/**
 * 修改维保单信息
 */
export const upDateMaintainInfo = data => axios('/valueAdded/updateSpFxMaintenance', data, 'put')

/**
 * 取消工单预约
 */
// export const dancelInstallOrder = (enterpriseid, billno, type) => axios('/maintenance/checkservicestatus', {enterpriseid, billno, type}, 'get', 'method')


/**
* 获取服务商接口
*/

export const upDateServiceInfo = data => axios('/linkCarsIplat/updateTermnoInfo', data, 'post')



export const getService = (param) => axios_true(param).then(res => {return res});

/**
 * 发送评价信息
 */

export const sendRate = param => axios('/servicerCommentRestService/insertServiceComment',param, 'post');




 /**
 * 以下为我的车辆接口
 */


export const getCarInfo = param => axios('/getvipcarinfo', param);
 /**
 * 获取钱包余额
 */

export const selectPurseInfo = () => axios('/purse/selectPurseInfo');

/**
 * 获取优惠券使用明细
 */

// export const getvoucher = (param) => axios('/marketCenter/getCouponCodeListByUserId', param, 'get', 'other', true);
export const getCouponCodeCountOfUser = (param) => axios('/marketCenter/getCouponCodeCountOfUser', param, undefined, undefined, true);

/**
 * 获取礼品卡余额
 */

export const getWaitActivationCardCount = (param) => axios('/giftCardSalesAPI/getWaitActivationCardCount', param);

 /**
 * 用户地址接口
 */

 export const getAddress = param => axios('address/getarealist', param , 'get', 'method');


  /**
 * 消息
 */

export const findMessageList = param => axios('/messageVue/findMessageList', param, 'post');

/**
 * 已读消息改变
 */


// export const changeNews = rid => axios('/broadCast/updateBroadCastFromH5', {rid}, "put");

  /**
 * 收藏
 */


  /**
 * 以下为服务中心接口
 */

 /**
 * 意见类型
 */

export const queryQaCategoryList = (status=1, fromPc=false )=> axios('/qaCategoryRestService/queryQaCategoryList',{status, fromPc}, 'post')


 /**
 * 意见反馈
 */

export const submitQaAdvice = (categoryName, categoryId, qDesc, qPhone, status=1)=> axios('/qaAdviceRestService/insertQaAdviceFromH5',{categoryName, categoryId, qDesc, qPhone, status}, 'post')

  /**
 * 常见问题
 */

export const questionList = (describle, status=1)=> axios('/qaAnswerRestService/queryQaAnswerListFromH5',{describle, status}, 'post')

/**
 * 以下为签到
 */

/**
 * 查询当天签到记录数量接口
 */


export const getSignDetailCountByToday = param => axios('/signRewardApi/getSignDetailCountByToday')

/**
 * 获取可用的签到活动
 */

export const getEnableSignRule = param => axios('/signRewardApi/getEnableSignRule')

/**
 * 获取某用户最新签到记录
 */

export const getSignDetailByLatest = param => axios('/signRewardApi/getSignDetailByLatest', param, 'get', 'other')
 

 /**
 * 提交某用户最新签到记录
	 paramers signRuleId = 69
	 paramers signItemId
 */

 export const saveSignDetail = param => axios('/signRewardApi/saveSignDetail', param, 'get', 'other')

 /**
  * 以下为抽奖
  */

/**
 * 九宫格抽奖
 */
 
  /**
   * 获取抽奖规则及详情讯息
   */

  export const getRewardRuleAndDetailForHome = param => axios('/signRewardApi/getRewardRuleAndDetailForHome', param, 'get', 'other')

  /**
   * 提交某用户抽奖记录
   */

  export const getRandomRewardItem = param => axios('/signRewardApi/getRandomRewardItem', param, 'get', 'other')

  /**
   * 某用户签到历史记录
   */

  export const getMonthHistorySignDetailList = param => axios('/signRewardApi/getMonthHistorySignDetailList', param, 'get', 'other')



	/**
	 * 某用户抽奖历史记录
	 */

	export const getSignRewardToday = param => axios('/signRewardApi/getSignRewardToday', param, 'get', 'other')

  /**
   * 查询用户积分
   */

  export const getUserIntegral = () => axios('/signRewardApi/getUserIntegral')

  /**
   * 查询是否可以抽奖
   */

  export const getTodayRewardResultDetailForHome = param => axios('/signRewardApi/getTodayRewardResultDetailForHome', param, undefined, 'other');

/**
 * 翻牌抽奖
 */

/**
 * 翻牌抽奖规则
 */

  export  const getSpecialRewardRuleAndDetailForHome = param => axios('/specialRewardApi/getSpecialRewardRuleAndDetailForHome', param, undefined, 'other', undefined, {type:1});
  
  /**
 * 查询以抽奖和剩余抽奖次数
 */
  export  const getSpecialRewardResultDetailForHome = param => axios('/specialRewardApi/getSpecialRewardResultDetailForHome', param, undefined, 'other', undefined, {type:1});

/**
 * 付款码
 */

/**
 * 获取待支付订单接口
 */

export  const getWaitPayOffLineOrderInfo = param => axios('/offLine/getWaitPayOffLineOrderInfo', param, 'post', undefined, true, {type:1});

/**
 * 钱包支付
 */
// offLine
export  const walletPayOffLineOrder = param => axios('/offLine/walletPayOffLineOrder', param, 'post', undefined, true, {type:1});


/**
 * 溯源码
 */

// export  const findByCode = param => axios('/baseConfig/findByCode', param, undefined, undefined, {config:1}, {type:1});

/**
 * 保存设备信息，推送用，zwy建
 */

export  const saveDeviceInfo = param => axios('/customer/saveDeviceInfo', param, 'post');

/**
 * 记录消息推送次数，推送用，zwy建
 */

export  const countClickNum = param => axios('/pushMessage/countClickNum', param, 'post');

export const findByCode = param => axios_true({
  method:'get',
  url: `${api.base_host}/baseConfig/findByCode`,
  headers: {'sessionId': localStorage.getItem('sessionId'), 'Content-Type':'application/json', 'Accept' : 'application/json'}
}).then(res => {return res});